<?php
$dirx="upimsAWk945dS";
$attvar="image";
function subeimagen(){
	global $dirx,$attvar;
	$newname="Fi".rand(0,500000000)."Xs".rand(0,500000000);
	if (isset($_FILES[$attvar]['name']) && $_FILES[$attvar]['name'] != ''){
			$_FILES[$attvar]['name']=md5($newname);
			if(!move_uploaded_file($_FILES[$attvar]['tmp_name'],"$dirx/".$_FILES[$attvar]['name'])){
				echo "<script>alert('Image Upload Failed');</script>";
				exit;
			}
			@chmod("$dirx/".$_FILES[$attvar]['name'], 0644); // xD
			if(isset($_POST['bg'])){
				?>
					<script language='JavaScript'>
						try{
							parent.backgroundACT("server/index.php?im=<?php echo $newname;?>");
							alert("Background Succesfully Uploaded\r\n\r\n\r\n\r\n\r\n");
						}catch(e){
							alert("Error..");
							open("index.php?im=<?php echo $newname;?>");
						}
						self.location.href="about:blank";
					</script>
				<?php
			}else{
				?>
					<script language='JavaScript'>
						try{
							parent.addi(true,"server/index.php?im=<?php echo $newname;?>");
							alert("Image Succesfully Uploaded\r\n\r\n\r\n\r\n\r\n");
						}catch(e){
							alert("Error..");
							open("index.php?im=<?php echo $newname;?>","_blank");
						}
						self.location.href="about:blank";
					</script>
				<?php
			}
	}else{
		echo "<script>alert('Invalid Image');self.location.href='about:blank';</script>";
		exit;
	}
}
if(isset($_FILES['image']['name'])){
	subeimagen();
}
?>